/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.axiom.ui;

import com.axiom.vo.user_detail;
import javax.swing.ImageIcon;
import javax.swing.UIManager;

/**
 *
 * @author Shuhail
 */
public class StartHere extends javax.swing.JFrame {

    /**
     * Creates new form StartHere
     */
    public StartHere() {
        changeTheLookAndFeel();
        initComponents();
        hideAll();
        
        this.userNameDisplay.setText("Logged in as : "+detail.getName());
        this.roleDisplay.setText("Role :"+detail.getRole());
        
        
    }
    
    
    public void start(user_detail detail) {
        
       
        
    }
    
    
    private void validateRolePrivilege() {
        
        if(!detail.getRole().equals("ADMIN")) {
            
            this.addUser.setEnabled(false);
          
            this.newStudent.setEnabled(false);
            this.newCourseButton.setEnabled(false);
            
        }
    }
    public void changeTheLookAndFeel() {
        
         try {
            
            UIManager.setLookAndFeel(
            UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
    }
    
    public void hideAll() {
        
        System.out.println(detail.getName()+"---"+detail.getRole());
        this.newStudent.setVisible(false);
        this.viewCurremt.setVisible(false);
        this.newCourseButton.setVisible(false);
        this.viewCourseVariable.setVisible(false);
        this.viewTeacherButton.setVisible(false);
        this.newTeacherButton.setVisible(false);
        this.feesPayment.setVisible(false);
        this.viewAccounts.setVisible(false);
        this.addUser.setVisible(false);
        this.viewUsers.setVisible(false);
       
        this.studentDetails.setVisible(false);
        this.instructorSave.setVisible(false);
        this.courseSave.setVisible(false);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        newStudent = new javax.swing.JButton();
        viewCurremt = new javax.swing.JButton();
        Course = new javax.swing.JButton();
        newCourseButton = new javax.swing.JButton();
        viewCourseVariable = new javax.swing.JButton();
        teacher = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JSeparator();
        viewTeacherButton = new javax.swing.JButton();
        newTeacherButton = new javax.swing.JButton();
        cashManagement = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        feesPayment = new javax.swing.JButton();
        viewAccounts = new javax.swing.JButton();
        userNameDisplay = new javax.swing.JLabel();
        roleDisplay = new javax.swing.JLabel();
        jSeparator4 = new javax.swing.JSeparator();
        jButton2 = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        addUser = new javax.swing.JButton();
        viewUsers = new javax.swing.JButton();
        logoutButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        studentDetails = new javax.swing.JButton();
        instructorSave = new javax.swing.JButton();
        courseSave = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("AXIONS GROUP OF INSTITUTIONS");

        jPanel1.setBackground(new java.awt.Color(153, 153, 255));
        jPanel1.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jButton1.setIcon(new javax.swing.ImageIcon("C:\\Users\\Shuhail\\Desktop\\studentnew1.png")); // NOI18N
        jButton1.setToolTipText("Student Management");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(18, 11, 156, 119));
        jPanel1.add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 148, 1350, 10));

        newStudent.setText("New Reg");
        newStudent.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newStudentActionPerformed(evt);
            }
        });
        jPanel1.add(newStudent, new org.netbeans.lib.awtextra.AbsoluteConstraints(248, 11, 140, 47));

        viewCurremt.setText("View/Remove Existing");
        viewCurremt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewCurremtActionPerformed(evt);
            }
        });
        jPanel1.add(viewCurremt, new org.netbeans.lib.awtextra.AbsoluteConstraints(248, 65, -1, 51));

        Course.setIcon(new javax.swing.ImageIcon("C:\\Users\\Shuhail\\Desktop\\courses.jpg")); // NOI18N
        Course.setToolTipText("Course Management");
        Course.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CourseActionPerformed(evt);
            }
        });
        jPanel1.add(Course, new org.netbeans.lib.awtextra.AbsoluteConstraints(19, 169, 159, 119));

        newCourseButton.setText("New Course");
        newCourseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newCourseButtonActionPerformed(evt);
            }
        });
        jPanel1.add(newCourseButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(251, 169, 140, 43));

        viewCourseVariable.setText("View/Remove Course");
        viewCourseVariable.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewCourseVariableActionPerformed(evt);
            }
        });
        jPanel1.add(viewCourseVariable, new org.netbeans.lib.awtextra.AbsoluteConstraints(251, 230, 140, 43));

        teacher.setIcon(new javax.swing.ImageIcon("C:\\Users\\Shuhail\\Desktop\\teacher.jpg")); // NOI18N
        teacher.setToolTipText("Teacher Management");
        teacher.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                teacherActionPerformed(evt);
            }
        });
        jPanel1.add(teacher, new org.netbeans.lib.awtextra.AbsoluteConstraints(21, 327, 157, 128));
        jPanel1.add(jSeparator3, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 306, 1350, 10));

        viewTeacherButton.setText("View Teachers");
        viewTeacherButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewTeacherButtonActionPerformed(evt);
            }
        });
        jPanel1.add(viewTeacherButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(255, 327, -1, 38));

        newTeacherButton.setText("New Teacher");
        newTeacherButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newTeacherButtonActionPerformed(evt);
            }
        });
        jPanel1.add(newTeacherButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(255, 394, 101, 41));

        cashManagement.setIcon(new javax.swing.ImageIcon("C:\\Users\\Shuhail\\Desktop\\cashnew.jpg")); // NOI18N
        cashManagement.setToolTipText("Account Management");
        cashManagement.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cashManagementActionPerformed(evt);
            }
        });
        jPanel1.add(cashManagement, new org.netbeans.lib.awtextra.AbsoluteConstraints(22, 494, 158, 100));
        jPanel1.add(jSeparator2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 473, 1350, 10));

        feesPayment.setText("Manage Fees");
        feesPayment.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                feesPaymentActionPerformed(evt);
            }
        });
        jPanel1.add(feesPayment, new org.netbeans.lib.awtextra.AbsoluteConstraints(255, 494, 104, 33));

        viewAccounts.setText("View Account");
        jPanel1.add(viewAccounts, new org.netbeans.lib.awtextra.AbsoluteConstraints(255, 545, 104, 34));

        userNameDisplay.setForeground(new java.awt.Color(0, 0, 51));
        jPanel1.add(userNameDisplay, new org.netbeans.lib.awtextra.AbsoluteConstraints(1190, 20, 158, 14));

        roleDisplay.setForeground(new java.awt.Color(0, 0, 51));
        jPanel1.add(roleDisplay, new org.netbeans.lib.awtextra.AbsoluteConstraints(1190, 60, 158, 20));
        jPanel1.add(jSeparator4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 610, 1350, 20));

        jButton2.setIcon(new javax.swing.ImageIcon("C:\\Users\\Shuhail\\Desktop\\people.jpg")); // NOI18N
        jButton2.setToolTipText("User Management");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 20, 160, 110));

        jPanel2.setBackground(new java.awt.Color(0, 0, 51));

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 10, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 610, Short.MAX_VALUE)
        );

        jPanel1.add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(570, 0, 10, 610));

        addUser.setBackground(new java.awt.Color(0, 102, 153));
        addUser.setText("Add User");
        addUser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addUserActionPerformed(evt);
            }
        });
        jPanel1.add(addUser, new org.netbeans.lib.awtextra.AbsoluteConstraints(880, 20, 80, 40));

        viewUsers.setText("View Users");
        jPanel1.add(viewUsers, new org.netbeans.lib.awtextra.AbsoluteConstraints(880, 80, -1, 40));

        logoutButton.setText("Logout");
        logoutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButtonActionPerformed(evt);
            }
        });
        jPanel1.add(logoutButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(1270, 100, -1, -1));

        saveButton.setIcon(new javax.swing.ImageIcon("C:\\Users\\Shuhail\\Documents\\NetBeansProjects\\AXIOM\\src\\img\\savePicture.jpg")); // NOI18N
        saveButton.setToolTipText("Save importand details to your Computer");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });
        jPanel1.add(saveButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(650, 180, 160, 110));

        studentDetails.setText("Student Details");
        jPanel1.add(studentDetails, new org.netbeans.lib.awtextra.AbsoluteConstraints(880, 180, 120, 40));

        instructorSave.setText("Instructor Details");
        jPanel1.add(instructorSave, new org.netbeans.lib.awtextra.AbsoluteConstraints(880, 240, 120, 40));

        courseSave.setText("Course Details");
        jPanel1.add(courseSave, new org.netbeans.lib.awtextra.AbsoluteConstraints(1030, 180, 110, 40));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 1355, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 20, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 675, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(0, 22, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        hideAll();
        validateRolePrivilege();
        this.newStudent.setVisible(true);
        this.viewCurremt.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed

    private void newStudentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newStudentActionPerformed
        // TODO add your handling code here:
        
        new StudentInfo().setVisible(true);
    }//GEN-LAST:event_newStudentActionPerformed

    private void viewCurremtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewCurremtActionPerformed
        // TODO add your handling code here:
        new ViewStudentAndCourses().setVisible(true);
    }//GEN-LAST:event_viewCurremtActionPerformed

    private void newCourseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newCourseButtonActionPerformed
        // TODO add your handling code here:
        new newCourse().setVisible(true);
    }//GEN-LAST:event_newCourseButtonActionPerformed

    private void viewCourseVariableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewCourseVariableActionPerformed
        // TODO add your handling code here:
        new viewAllCourses().setVisible(true);
    }//GEN-LAST:event_viewCourseVariableActionPerformed

    private void CourseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CourseActionPerformed
        // TODO add your handling code here:
        hideAll();
        validateRolePrivilege();
        
        this.newCourseButton.setVisible(true);
        this.viewCourseVariable.setVisible(true);
    }//GEN-LAST:event_CourseActionPerformed

    private void teacherActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_teacherActionPerformed
        // TODO add your handling code here:
        
        hideAll();
        validateRolePrivilege();
        
        this.viewTeacherButton.setVisible(true);
        this.newTeacherButton.setVisible(true);
    }//GEN-LAST:event_teacherActionPerformed

    private void cashManagementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cashManagementActionPerformed
        // TODO add your handling code here:
        hideAll();
        validateRolePrivilege();
        
        this.feesPayment.setVisible(true);
        this.viewAccounts.setVisible(true);
        
    }//GEN-LAST:event_cashManagementActionPerformed

    private void feesPaymentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_feesPaymentActionPerformed
        // TODO add your handling code here:
        new ManageFees().setVisible(true);
    }//GEN-LAST:event_feesPaymentActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // TODO add your handling code here:
        hideAll();
        validateRolePrivilege();
        
        this.addUser.setVisible(true);
        this.viewUsers.setVisible(true);
      
    }//GEN-LAST:event_jButton2ActionPerformed

    private void addUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addUserActionPerformed
        // TODO add your handling code here:
        
        new NewUser().setVisible(true);
    }//GEN-LAST:event_addUserActionPerformed

    private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed
        // TODO add your handling code here:
        
        this.dispose();
        new Axiom_Startup().setVisible(true);
    }//GEN-LAST:event_logoutButtonActionPerformed

    private void newTeacherButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newTeacherButtonActionPerformed
        // TODO add your handling code here:
        
        new NewInstructor().setVisible(true);
    }//GEN-LAST:event_newTeacherButtonActionPerformed

    private void viewTeacherButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewTeacherButtonActionPerformed
        // TODO add your handling code here:
        new ViewAllInstructors().setVisible(true);
    }//GEN-LAST:event_viewTeacherButtonActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        // TODO add your handling code here:
        hideAll();
        this.studentDetails.setVisible(true);
        this.instructorSave.setVisible(true);
        this.courseSave.setVisible(true);
    }//GEN-LAST:event_saveButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            
            UIManager.setLookAndFeel(
            UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(StartHere.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new StartHere().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Course;
    private javax.swing.JButton addUser;
    private javax.swing.JButton cashManagement;
    private javax.swing.JButton courseSave;
    private javax.swing.JButton feesPayment;
    private javax.swing.JButton instructorSave;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JSeparator jSeparator4;
    private javax.swing.JButton logoutButton;
    private javax.swing.JButton newCourseButton;
    private javax.swing.JButton newStudent;
    private javax.swing.JButton newTeacherButton;
    private javax.swing.JLabel roleDisplay;
    private javax.swing.JButton saveButton;
    private javax.swing.JButton studentDetails;
    private javax.swing.JButton teacher;
    private javax.swing.JLabel userNameDisplay;
    private javax.swing.JButton viewAccounts;
    private javax.swing.JButton viewCourseVariable;
    private javax.swing.JButton viewCurremt;
    private javax.swing.JButton viewTeacherButton;
    private javax.swing.JButton viewUsers;
    // End of variables declaration//GEN-END:variables

    public static user_detail detail = new user_detail();
}
